import Router from 'koa-router';
import proxyService from '../../common/proxyService';
import {
  getComponentListSmartForm,
  saveFormInfoSmartForm,
  updateFormInfoSmartForm,
  getFormInfoSmartForm,
  // getTemplateFormListSmartForm,
  getTmpIdSmartForm,
  saveTmpIdSmartForm,
  uploadCloudTokenSmartForm,
  checkRelationSmartForm,
  getFormStyleListSmartForm,
  getQrCodeImageSmartForm,
  getQrCodeImageFileSmartForm,
  getTemplateInfoSmartForm,
  getChannelListSmartForm,
  getSmartFormShareInfoSmartForm,
} from '../../api';

const router = new Router();

// 保存表单
router.post('/saveSmartForm', async ctx => {
  const response = await proxyService.postProxy(ctx, saveFormInfoSmartForm);
  return (ctx.body = response);
});
// 修改
router.post('/updateSmartForm', async ctx => {
  const response = await proxyService.postProxy(ctx, updateFormInfoSmartForm);
  return (ctx.body = response);
});
// 获取表单
router.get('/getSmartForm', async ctx => {
  const response = await proxyService.postProxy(ctx, getFormInfoSmartForm);
  return (ctx.body = response);
});
//
// 获取组件列表
router.get('/getItemList', async ctx => {
  const response = await proxyService.postProxy(ctx, getComponentListSmartForm);
  return (ctx.body = response);
});
//
router.get('/getFormStyleList', async ctx => {
  const response = await proxyService.postProxy(ctx, getFormStyleListSmartForm);
  return (ctx.body = response);
});

// 检查是否可以修改
router.get('/checkRelation', async ctx => {
  const response = await proxyService.postProxy(ctx, checkRelationSmartForm);
  return (ctx.body = response);
});
// 获取图片上传临时id
router.get('/getTmpId', async ctx => {
  const response = await proxyService.postProxy(ctx, getTmpIdSmartForm);
  return (ctx.body = response);
});
// 保存图片上传临时id和url
router.post('/saveTmpId', async ctx => {
  const response = await proxyService.postProxy(ctx, saveTmpIdSmartForm);
  return (ctx.body = response);
});
// 获取表单图片云上传 token
router.post('/uploadCloudToken', async ctx => {
  console.log(1231);
  const response = await proxyService.postProxy(ctx, uploadCloudTokenSmartForm);
  return (ctx.body = response);
});
// 查询推广渠道
router.get('/getChannelList', async ctx => {
  const response = await proxyService.postProxy(ctx, getChannelListSmartForm);
  return (ctx.body = response);
});

// 指定大小二维码下载
router.get('/getQrCodeImageFormOss', async ctx => {
  const response = await proxyService.postProxy(ctx, getQrCodeImageSmartForm);
  return (ctx.body = response);
});

router.get('/getQrCodeImageFile', async ctx => {
  const response = await proxyService.postProxy(ctx, getQrCodeImageFileSmartForm);
  return (ctx.body = response);
});

router.get('/getTemplateInfo', async ctx => {
  const response = await proxyService.postProxy(ctx, getTemplateInfoSmartForm);
  return (ctx.body = response);
});

router.get('/getSmartFormShareInfo', async ctx => {
  const response = await proxyService.postProxy(ctx, getSmartFormShareInfoSmartForm);
  return (ctx.body = response);
});

export default router;
